//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.mega.ycy.common.entity;

import com.mega.ycy.Yiciyuan_EVENT;
import java.awt.Color;
import mods.flammpfeil.slashblade.client.model.obj.Face;
import mods.flammpfeil.slashblade.client.model.obj.WavefrontObject;
import mods.flammpfeil.slashblade.client.renderer.entity.RenderSlashDimension;
import mods.flammpfeil.slashblade.entity.EntitySlashDimension;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;

public class DeleteRenderer extends RenderSlashDimension {
    public DeleteRenderer(RenderManager renderManager) {
        super(renderManager);
    }

    public void renderModel(Entity entity, double x, double y, double z, float yaw, float partialRenderTick) {
        if (model == null) {
            model = new WavefrontObject(modelLocation);
        }

        if (entity.ticksExisted > 60) {
            Yiciyuan_EVENT.killEntity(entity);
        } else {
            this.bindEntityTexture(entity);
            GL11.glPushMatrix();
            GL11.glPushAttrib(1048575);
            GL11.glShadeModel(7425);
            GL11.glDisable(2896);
            GL11.glEnable(3042);
            int color = 5592575; 
            if (entity instanceof EntitySlashDimension) {
                color = ((EntitySlashDimension)entity).getColor();
            }

            double baseAlpha = 0.5D;
            Color col = new Color(color);
            float[] hsb = Color.RGBtoHSB(col.getRed(), col.getGreen(), col.getBlue(), null);
            int baseColor = Color.getHSBColor(0.5F + hsb[0], hsb[1], 0.2F).getRGB() & 16777215;
            baseColor |= (int)(102.0D * baseAlpha) << 24;
            GL11.glTranslatef((float)x, (float)y, (float)z);
            float scale = 0.01F;
            GL11.glScalef(scale, scale, scale);
            float lastx = OpenGlHelper.lastBrightnessX;
            float lasty = OpenGlHelper.lastBrightnessY;
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
            Face.setColor(baseColor);
            OpenGlHelper.glBlendFunc(770, 1, 1, 0);
            GlStateManager.glBlendEquation(32779);
            GL11.glPushMatrix();
            GL11.glPopMatrix();
            double waveScale1 = 0.0D;
            double biggest = 20.0D;
            float wave = (float)entity.ticksExisted;
            if (waveScale1 < 15.0D) {
                waveScale1 = (double)wave;
                if (waveScale1 > biggest) {
                    waveScale1 = biggest;
                }
            }

            int loop = 1;

            for(int j = 0; j < loop; ++j) {
                GL11.glPushMatrix();
                GL11.glScaled(waveScale1, waveScale1, waveScale1);
                GL11.glColor4d(0.43921568989753723D, 0.501960813999176D, 0.4470588266849518D, 0.5D);
                model.renderPart("base");
                GL11.glPopMatrix();
            }

            GlStateManager.glBlendEquation(32774);
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastx, lasty);
            GL11.glDisable(3042);
            GL11.glEnable(2896);
            GL11.glShadeModel(7424);
            GL11.glPopAttrib();
            GL11.glPopMatrix();
            ++entity.ticksExisted;
        }
    }
}
